﻿@model MiniBlog.Core.ViewModels.PostView.EditPostViewModel

@{
    ViewData["Title"] = "博文内容";
}
    <style type="text/css">
        .w-e-text-container {
            height: 400px !important; 
        }
    </style>
<div class="row">
    <form asp-action="Content">
        <div class="col-md-4" style="display:none;">
            <div asp-validation-summary="ModelOnly" class="text-danger"></div>
            <div class="form-group" style="display:none;">
                <label asp-for="Id" class="control-label"></label>
                <input asp-for="Id" class="form-control" />
                <span asp-validation-for="Id" class="text-danger"></span>
            </div>
            <div class="form-group">
                <label asp-for="Content" class="control-label"></label>
                <input asp-for="Content" class="form-control" />
                <span asp-validation-for="Content" class="text-danger"></span>
            </div>
        </div>
        <div id="diveditor"></div>
        <input type="submit" value="提交" class="btn btn-primary" />
    </form>
</div>
@section Scripts {
    @{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
    <script type="text/javascript" src="~/wangeditor/wangEditor.min.js"></script>
    <script type="text/javascript">
        var E = window.wangEditor
        var diveditor = new E('#diveditor')
        var $Content = $('#Content')
        diveditor.customConfig.onchange = function (html) {
            // 监控变化，同步更新到 textarea
            $Content.val(html)
        }
        diveditor.create()
        // 初始化 textarea 的值
        diveditor.txt.html('@Html.Raw(Model.Content)')
    </script>
}
